package com.huluobo.a2204kotlinshopping.mine

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.bean.CommonBeanResult
import com.huluobo.base.bean.OrderTypeBean
import com.huluobo.base.bean.UserBean
import com.huluobo.base.viewmodel.BaseViewModel

/**
 *  Created by LC on 2024/8/3.
 */
class MineViewModel : BaseViewModel<MineRepo>() {
    val getUserDataSuccess = MutableLiveData<UserBean>()
    val getUserDataFailed = MutableLiveData<String>()

    val getAllOrdersSuccess = MutableLiveData<List<OrderTypeBean>>()
    val getAllOrdersFailed = MutableLiveData<String>()

    val updateAddressSuccess = MutableLiveData<CommonBeanResult>()
    val updateAddressFailed = MutableLiveData<String>()

    fun updateAddress(address: String) {
        repo.updateAddress(address, updateAddressSuccess, updateAddressFailed)
    }

    fun getAllOrders() {
        repo.getAllOrders(getAllOrdersSuccess, getAllOrdersFailed)
    }

    fun getUserData(username: String) {
        repo.queryUserData(username, getUserDataSuccess, getUserDataFailed)
    }

    override fun createRepo(): MineRepo = MineRepo()
}